package com.demo.zyt.modules.app.service.impl;


import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.demo.zyt.config.CommonParameters;
import com.demo.zyt.modules.app.dao.AreaDao;
import com.demo.zyt.modules.app.entity.AreaEntity;
import com.demo.zyt.modules.app.service.AreaService;


@Service("areaService")
public class AreaServiceImpl extends ServiceImpl<AreaDao, AreaEntity> implements AreaService {

	@Override
	public List<AreaEntity> selectByPid(String pid) {
		
		if ( StringUtils.isEmpty(pid) ) {
			EntityWrapper<AreaEntity> wrapper = new EntityWrapper<>();
			
			wrapper.eq("level", CommonParameters.AREA_LEVEL.PROVINCE);
			
			return this.selectList(wrapper);
		} else {
			EntityWrapper<AreaEntity> wrapper = new EntityWrapper<>();
			
			wrapper.eq("pid", Integer.parseInt(pid));
			
			return this.selectList(wrapper);
		}
	}
	
	
}
